package edu.cuit.canary.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Controller
@RefreshScope
public class PropertiesController {
    /**
     * 拉取配置中心属性内容
     */
    @Value("${datetime.pattern}")
    private String pattern;

    @GetMapping("/time/show")
    @ResponseBody
    public String showTime() {
        var time = LocalDateTime.now();
        System.out.println("pattern:" + pattern);
        return DateTimeFormatter.ofPattern(pattern).format(time);
    }
}
